package com.tvsinfo.jdk.demo.case2_function_interface;

import com.tvsinfo.jdk.demo.case2_function_interface.dto.Car;

import java.util.function.Supplier;

public class SupplierDemo {


    public static void main(String[] args) {


        SupplierDemo supplierDemo = new SupplierDemo();
        supplierDemo.demoStart();
    }


    public void demoStart() {
        //例子
        Supplier supplier = () -> new SupplierDemo();
        Supplier supplier1 = SupplierDemo::new;

        //实战
        Supplier supplier2 = () -> new Car("法拉利", 54000, "中蓝", 5000);
        Supplier supplier3 = () -> getInstance();
        test(supplier3);
    }


    public Car getInstance() {
        return new Car("法拉利", 54000, "中蓝", 5000);
    }

    public void test(Supplier supplier) {
        if (null != supplier.get()) {
            System.out.println(supplier.get());
        }
    }
}
